/**
 * @file	bleuart_service.h
 * @author	chipsea
 * @brief	
 * @version	0.1
 * @date	2020-11-30
 * @copyright Copyright (c) 2020, CHIPSEA Co., Ltd.
 * @note
 */
#ifndef __BLEUART_SERVICE_H__
#define __BLEUART_SERVICE_H__

#include "att.h"
#include "types.h"
#include "bcomdef.h"

#ifdef __cplusplus
extern "C"
{
#endif

///< Simple Profile Service UUID
#define BLE_UART_SERV_UUID		0xFFF0
    
///< UART TRX UUID
#define BLE_UART_CHAR1_UUID		0xFFF1
#define BLE_UART_CHAR2_UUID		0xFFF2


#define RAWPASS_RX_BUFF_SIZE	1

#define RAWPASS_TX_VALUE_HANDLE	2
#define RAWPASS_RX_VALUE_HANDLE	5
#define RAWPASS_AT_VALUE_HANDLE	7
enum
{
    BLE_EVT_TX_NOTI_DISABLED = 1,
    BLE_EVT_TX_NOTI_ENABLED,
    BLE_EVT_BLE_DATA_RECIEVED,
};

extern  uint8 bleuart_ServiceUUID[ATT_UUID_SIZE];
extern  uint8 bleuart_TxCharUUID[ATT_UUID_SIZE];
extern  uint8 bleuart_RxCharUUID[ATT_UUID_SIZE];
extern  uint8 bleuart_AT_UUID[ATT_UUID_SIZE];
/*********************************************************************
 * FUNCTIONS
 */


typedef struct{
    uint8_t   ev;
    uint8_t   role;
    uint16_t  channel;
    uint16_t  param;
    uint8_t*  data;
}ble_data_evt_t;
typedef void (*bleuart_ProfileChangeCB_t)(ble_data_evt_t* pev);

typedef struct
{
    uint8_t flag;
    uint8_t main_service[2];
    uint8_t notify[2];
    uint8_t wr[2];
    uint8_t at[2];
    uint8_t bit128_base[16];

}ble_service_t;

bStatus_t bleuart_AddService( void);
uint16_t bleuart_NotifyIsReady(uint16 connHandle);
bStatus_t bleuart_Notify( uint16 connHandle, attHandleValueNoti_t *pNoti);
//bStatus_t bleuart_Notify_AT (uint16 connHandle, attHandleValueNoti_t *pNoti);
bStatus_t bleuart_Notify_AT (uint8_t index, attMsg_t *msg);
bStatus_t bleuart_DeleteService(void);
void ble_set_custom_serviceUUID(uint8 uuid_type, ble_service_t uuid);
bStatus_t ble_AddCustomService(uint8 uuid_type);
void ble_get_custom_serviceUUID(ble_service_t *uuid);
void ble_service_init(void);
/*********************************************************************
*********************************************************************/

#ifdef __cplusplus
}
#endif

#endif /* BLEUART_SERVICE_H */
